<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入理解 JVM 内部结构</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            border-color: rgba(102, 126, 234, 0.3);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 30px;
            background: linear-gradient(to bottom, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 15px;
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        
        .mermaid {
            background: white;
            padding: 30px;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .first-letter {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        
        .component-card {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
            transition: all 0.3s ease;
        }
        
        .component-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-fadeInUp">
                深入理解 JVM 内部结构
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto animate-fadeInUp" style="animation-delay: 0.2s;">
                探索 Java 虚拟机的核心组件与工作原理，掌握高性能 Java 应用的基石
            </p>
            <div class="mt-10 flex justify-center space-x-8 animate-fadeInUp" style="animation-delay: 0.4s;">
                <div class="text-center">
                    <i class="fas fa-microchip text-3xl mb-2"></i>
                    <p class="text-sm opacity-80">高效执行引擎</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-memory text-3xl mb-2"></i>
                    <p class="text-sm opacity-80">智能内存管理</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-shield-alt text-3xl mb-2"></i>
                    <p class="text-sm opacity-80">跨平台兼容</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-7xl mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="mb-16">
            <div class="component-card">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="first-letter">J</span>ava 虚拟机（JVM）是一个复杂的软件系统，它负责执行 Java 字节码、管理内存、提供跨平台兼容性等。JVM 的内部结构包括多个关键组件和子系统，它们协同工作以确保 Java 程序的高效运行。理解这些组件的工作原理，是成为高级 Java 开发者的必经之路。
                </p>
            </div>
        </section>

        <!-- JVM Architecture Diagram -->
        <section class="mb-16">
            <h2 class="text-3xl font-bold mb-8 text-center text-gray-800">JVM 架构全景图</h2>
            <div class="mermaid">
                graph TB
                    subgraph "JVM 架构"
                        A[Java 源代码] --> B[Java 编译器]
                        B --> C[字节码文件 .class]
                        C --> D[类加载器子系统]
                        
                        D --> E[运行时数据区]
                        
                        subgraph "运行时数据区"
                            E1[程序计数器]
                            E2[虚拟机栈]
                            E3[本地方法栈]
                            E4[堆]
                            E5[方法区/Metaspace]
                        end
                        
                        E --> F[执行引擎]
                        
                        subgraph "执行引擎"
                            F1[解释器]
                            F2[JIT 编译器]
                            F3[垃圾回收器]
                        end
                        
                        F --> G[本地接口]
                        G --> H[本地方法库]
                    end
                    
                    style A fill:#e1f5fe
                    style B fill:#b3e5fc
                    style C fill:#81d4fa
                    style D fill:#4fc3f7
                    style E fill:#29b6f6
                    style F fill:#03a9f4
                    style G fill:#039be5
                    style H fill:#0288d1
            </div>
        </section>

        <!-- Class Loader Subsystem -->
        <section class="mb-16">
            <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">
                <i class="fas fa-download mr-3 text-purple-600"></i>类加载器子系统
            </h2>
            
            <div class="grid md:grid-cols-3 gap-6 mb-8">
                <div class="card-hover bg-white rounded-lg p-6">
                    <div class="feature-icon">
                        <i class="fas fa-file-upload"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">加载（Loading）</h3>
                    <p class="text-gray-600">从各种来源（如文件系统、网络）加载 <code class="bg-gray-100 px-2 py-1 rounded">.class</code> 文件，将字节码读入内存。</p>
                </div>
                
                <div class="card-hover bg-white rounded-lg p-6">
                    <div class="feature-icon">
                        <i class="fas fa-link"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">链接（Linking）</h3>
                    <p class="text-gray-600">验证类文件的正确性，准备类的静态字段，解析类中的符号引用，确保类的完整性。</p>
                </div>
                
                <div class="card-hover bg-white rounded-lg p-6">
                    <div class="feature-icon">
                        <i class="fas fa-play-circle"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">初始化（Initialization）</h3>
                    <p class="text-gray-600">初始化类变量和执行静态初始化块，为类的使用做好最后准备。</p>
                </div>
            </div>

            <div class="highlight-box">
                <h4 class="text-lg font-semibold mb-3 text-gray-800">
                    <i class="fas fa-layer-group mr-2"></i>类加载器层次结构
                </h4>
                <ul class="space-y-2 text-gray-700">
                    <li><i class="fas fa-chevron-right mr-2 text-purple-600"></i><strong>Bootstrap ClassLoader：</strong>加载核心 Java 类库，如 <code class="bg-gray-100 px-2 py-1 rounded">java.lang.Object</code></li>
                    <li><i class="fas fa-chevron-right mr-2 text-purple-600"></i><strong>Platform ClassLoader：</strong>加载应用程序的类路径中的类</li>
                    <li><i class="fas fa-chevron-right mr-2 text-purple-600"></i><strong>Custom ClassLoader：</strong>用户定义的类加载器，用于加载特定类资源</li>
                </ul>
            </div>
        </section>

        <!-- Runtime Data Areas -->
        <section class="mb-16">
            <h2 class="section-title text-3xl font-bold mb-8 text-gray-800">
                <i class="fas fa-database mr-3 text-purple-600"></i>运行时数据区
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6">
                <div class="component-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-user mr-3 text-blue-600"></i>线程私有区域
                    </h3>
                    <div class="space-y-4">
                        <div class="border-l-4 border-blue-500 pl-4">
                            <h4 class="font-semibold text-gray-800">程序计数器</h4>
                            <p class="text-gray-600 text-sm mt-1">记录当前线程正在执行的字节码指令地址，线程切换后能恢复到正确的执行位置。</p>
                        </div>
                        <div class="border-l-4 border-blue-500 pl-4">
                            <h4 class="font-semibold text-gray-800">虚拟机栈</h4>
                            <p class="text-gray-600 text-sm mt-1">存储方法调用时的局部变量、操作数栈、动态链接、返回地址等信息。</p>
                        </div>
                        <div class="border-l-4 border-blue-500 pl-4">
                            <h4 class="font-semibold text-gray-800">本地方法栈</h4>
                            <p class="text-gray-600 text-sm mt-1">支持 JNI 调用，存储本地方法的调用信息。</p>
                        </div>
                    </div>
                </div>
                
                <div class="component-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-users mr-3 text-green-600"></i>线程共享区域
                    </h3>
                    <div class="space-y-4">
                        <div class="border-l-4 border-green-500 pl-4">
                            <h4 class="font-semibold text-gray-800">堆（Heap）</h4>
                            <p class="text-gray-600 text-sm mt-1">存储 Java 对象和数组，是垃圾回收的主要区域，分为年轻代和老年代。</p>
                        </div>
                        <div class="border-l-4 border-green-500 pl-4">
                            <h4 class="font-semibold text-gray-800">方法区/Metaspace</h4>
                            <p class="text-gray-600 text-sm mt-1">存储类的结构信息、运行时常量池、字段和方法数据等元数据。</p>
                        </div>
                        <div class="border-l-4 border-green-500 pl-4">
                            <h4 class="font-semibold text-gray-800